/**
 * Copyright &copy; 2012-2017 <a href="https://vivo.com">vivo</a> All rights reserved.
 */
package com.vivo.dealer.service;

import java.util.List;

import com.vivo.wares.entity.WaresSerial;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.vivo.dealer.entity.VivoWares;
import com.vivo.dealer.dao.VivoWaresDao;

/**
 * 商品Service
 * @author jyangye
 * @version 2017-11-07
 */
@Service
@Transactional(readOnly = true)
public class VivoWaresService extends CrudService<VivoWaresDao, VivoWares> {

    @Autowired
    private VivoWaresDao vivoWaresDao;


    public List<VivoWares> getWhenSerialIsNull(VivoWares vivoWares) {
        return vivoWaresDao.getWhenSerialIsNull(vivoWares);
    }

	public VivoWares get(String id) {
		return super.get(id);
	}

	public VivoWares get(VivoWares vivoWares) {
		return super.get(vivoWares);
	}
	public VivoWares getByWaresId(VivoWares vivoWares) {
		return vivoWaresDao.getByWaresId(vivoWares);
	}


	public VivoWares getByWaresName(VivoWares vivoWares) {

        List<VivoWares> list = vivoWaresDao.getByWaresName(vivoWares);
        if (list.size() > 0) {
            return list.get(0);
        }

        return null;
	}

	public List<WaresSerial> findSerialList(WaresSerial waresSerial) {
        return vivoWaresDao.findSerialList(waresSerial);
    }

    public Page<WaresSerial> findSerialPage(Page<WaresSerial> page, WaresSerial waresSerial) {
        waresSerial.setPage(page);
        page.setList(vivoWaresDao.findSerialList(waresSerial));
        return page;
    }

	public List<VivoWares> findList(VivoWares vivoWares) {
		return super.findList(vivoWares);
	}
	
	public Page<VivoWares> findPage(Page<VivoWares> page, VivoWares vivoWares) {
		return super.findPage(page, vivoWares);
	}
	
	@Transactional(readOnly = false)
	public void save(VivoWares vivoWares) {
		super.save(vivoWares);
	}
	
	@Transactional(readOnly = false)
	public void delete(VivoWares vivoWares) {
		super.delete(vivoWares);
	}
	
}